package com.hckjsec.official.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hckjsec.common.annotation.Log;
import com.hckjsec.common.core.controller.BaseController;
import com.hckjsec.common.core.domain.AjaxResult;
import com.hckjsec.common.enums.BusinessType;
import com.hckjsec.official.domain.OfficialLogininfor;
import com.hckjsec.official.service.IOfficialLogininforService;
import com.hckjsec.common.utils.poi.ExcelUtil;
import com.hckjsec.common.core.page.TableDataInfo;

/**
 * 系统访问记录Controller
 * 
 * @author cyt
 * @date 2021-12-10
 */
@RestController
@RequestMapping("/official/logininfor")
public class OfficialLogininforController extends BaseController
{
    @Autowired
    private IOfficialLogininforService officialLogininforService;

    /**
     * 查询系统访问记录列表
     */
    @GetMapping("/list")
    public TableDataInfo list(OfficialLogininfor officialLogininfor)
    {
        startPage();
        List<OfficialLogininfor> list = officialLogininforService.selectOfficialLogininforList(officialLogininfor);
        return getDataTable(list);
    }

    /**
     * 导出系统访问记录列表
     */
    @Log(title = "系统访问记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OfficialLogininfor officialLogininfor)
    {
        List<OfficialLogininfor> list = officialLogininforService.selectOfficialLogininforList(officialLogininfor);
        ExcelUtil<OfficialLogininfor> util = new ExcelUtil<OfficialLogininfor>(OfficialLogininfor.class);
        return util.exportExcel(list, "logininfor");
    }

    /**
     * 获取系统访问记录详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(officialLogininforService.selectOfficialLogininforById(id));
    }

    /**
     * 新增系统访问记录
     */
    @Log(title = "系统访问记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OfficialLogininfor officialLogininfor)
    {
        return toAjax(officialLogininforService.insertOfficialLogininfor(officialLogininfor));
    }

    /**
     * 修改系统访问记录
     */
    @Log(title = "系统访问记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OfficialLogininfor officialLogininfor)
    {
        return toAjax(officialLogininforService.updateOfficialLogininfor(officialLogininfor));
    }

    /**
     * 删除系统访问记录
     */
    @Log(title = "系统访问记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(officialLogininforService.deleteOfficialLogininforByIds(ids));
    }
}
